<?php

namespace app\api\validate\questions;

use think\Validate;

class Question extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
	    'id|标识' => 'require|number|>:0',
	    'type|考试类型' => 'number|>:0',
        'category|分类' => 'number|>=:0',
        'examination_type|考试类别' => 'require|number|>:0',
        'qid|问题id' => 'require|number|>:0',
        'list|答题卡' => 'require|array'
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [];

    /**
     * 定义场景
     * @var []
     */
    protected $scene = [
        'recommend' => ['type'],
        'answer' => ['id'],
        'categoryControl' => ['examination_type'],
        'submission' => ['qid','list']
    ];

    /**
     * 定义登录场景验证
     * @return $this
     */
    public function sceneCategory()
    {
        return $this->only(['category'])
            ->remove('category', 'require');
    }

}
